@import './mixins/mixins.scss';
@import './common/var.scss';
@import './mixins/utils.scss';
@import './mixins/_button.scss';

@include b(button){
  display: inline-block;
  line-height: $--line-height-none;
  text-align: center;
  cursor: pointer;
  outline: none;
  margin: 0;
  -webkit-transition-duration: .1s;
  transition-duration: .1s;

  padding:$--button-padding-vertical $--button-padding-horizontal;
  font-size: $--button-font-size;
  font-weight: $--button-font-weight;
  border-radius: $--button-border-radius;

  @include utils-user-select();

  & + & {
    margin-left:10px;
  }

  border:$--border-base;
  background-color:$--button-default-background-color ;
  border-color: $--button-default-border-color;
  color:$--button-default-font-color;

  &:hover,&:focus {
    background-color: $--color-primary-light-9;
    border-color: $--color-primary-light-7;
    color:$--color-primary;
  }

  &:active {
    border-color: mix($--color-black,$--color-primary,$--button-active-shade-percent);
    color:mix($--color-black,$--color-primary,$--button-active-shade-percent);
  }

  [class*='ml-icon-'] {
    & + span{
      margin-left: 5px;
    }
  }

  .ml-icon--left{
    margin-right: 5px;
  }

  .ml-icon--right{
    margin-left: 5px;
  }

  @include when(plain){
    &:hover,&:focus{
      background-color: $--color-white;
      border-color: $--color-primary;
      color:$--color-primary;
    }
    &:active{
      background-color: $--color-primary;
      border-color: $--color-primary;
      color:$--color-white;
    }
  }

  @include when(round){
    @include button-round();
  }

  @include when(circle){
    @include button-circle();
  }

  @include when(disabled){
    &,&.is-plain{
      cursor: not-allowed;
      background-color: $--button-disabled-background-color;
      border-color:$--button-disabled-border-color;
      color:$--button-disabled-color;
    }
  }

  @include when(loading){
    &,&.is-plain{
      cursor: not-allowed;
      background-color: $--button-disabled-background-color;
      border-color:$--button-disabled-border-color;
      color:$--button-disabled-color;
    }
  }

  @include m(primary){
    @include button-variant($--button-primary-background-color,$--button-primary-border-color,$--button-primary-font-color);
  }
  @include m(success){
    @include button-variant($--button-success-background-color,$--button-success-border-color,$--button-success-font-color);
  }
  @include m(warning){
    @include button-variant($--button-warning-background-color,$--button-warning-border-color,$--button-warning-font-color);
  }
  @include m(danger){
    @include button-variant($--button-danger-background-color,$--button-danger-border-color,$--button-danger-font-color);
  }
  @include m(info){
    @include button-variant($--button-info-background-color,$--button-info-border-color,$--button-info-font-color);
  }

  @include m(text){
    padding-left: 0;
    padding-right: 0;
    background-color:$--color-transparent;
    border-color:$--color-transparent;
    color:$--color-primary;

    &:hover,&:focus {
      background-color: $--color-transparent;
      border-color:$--color-transparent;
      color: mix($--color-white,$--color-primary,$--button-active-shade-percent);
    }

    &:active {
      color: mix($--color-black,$--color-primary,$--button-active-shade-percent);
    }

    &.is-disabled,&.is-disabled:hover,&.is-disabled:focus,&.is-loading,&.is-loading:hover,&.is-loading:focus{
      border-color: $--color-transparent;
      color:$--button-disabled-color;
    }
    
  }

  @include m(medium){
    @include button-size($--button-medium-border-radius,$--button-medium-padding-vertical,$--button-medium-padding-horizontal,$--button-medium-font-size);
  }
  @include m(small){
    @include button-size($--button-small-border-radius,$--button-small-padding-vertical,$--button-small-padding-horizontal,$--button-small-font-size);
  }
  @include m(mini){
    @include button-size($--button-mini-border-radius,$--button-mini-padding-vertical,$--button-mini-padding-horizontal,$--button-mini-font-size);
  }
}